package com.darren.befriend.fragments;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.darren.befriend.BaseActivity;
import com.darren.befriend.HomeActivity;
import com.darren.befriend.R;
import com.darren.befriend.UserSettingInitialActivity;
import com.darren.befriend.constants.Constant;

public class SportsFragment extends HobbyBaseFragment {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		interestTextArr = getResources().getStringArray(R.array.sport_text_arr);
		mInterestResIds = new int[] { R.drawable.s0, R.drawable.s1,
				R.drawable.s2, R.drawable.s3, R.drawable.s4, R.drawable.s5,
				R.drawable.s6, R.drawable.s7, R.drawable.s8, R.drawable.s9,
				R.drawable.s10, R.drawable.s11, R.drawable.s12, R.drawable.s13,
				R.drawable.s14, R.drawable.s15, R.drawable.s16, R.drawable.s17,
				R.drawable.s18, R.drawable.s19, R.drawable.s20, R.drawable.s21,
				R.drawable.s22, R.drawable.s23, R.drawable.s24, R.drawable.s25,
				R.drawable.s26, R.drawable.s27, R.drawable.s28, R.drawable.s29,
				R.drawable.s30, R.drawable.s31, R.drawable.s32, R.drawable.s33,
				R.drawable.s34, R.drawable.s35, R.drawable.s36, R.drawable.s37,
				R.drawable.s38, R.drawable.s39, R.drawable.s40, R.drawable.s41,
				R.drawable.s42, R.drawable.s43, R.drawable.s44, R.drawable.s45,
				R.drawable.s46, R.drawable.s47 };
		if (getArguments() != null) {
			MODE_VALUE = getArguments().getInt(MODE, 0);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {

		mCurrentUser = ((BaseActivity) getActivity()).getCurrentUser();
		if (mCurrentUser != null) {
			mSelected = (ArrayList<Boolean>) mCurrentUser.get("SPORTS");
		}

		super.onActivityCreated(savedInstanceState);
		mTitle = getString(R.string.sport);
		if (getActivity() instanceof UserSettingInitialActivity) {
			((UserSettingInitialActivity) getActivity())
					.setActivityTitle(mTitle);
			if (MODE_VALUE == FIRST_MODE) {
				((UserSettingInitialActivity) getActivity())
						.setNavigationImage(R.drawable.item_inter,
								R.drawable.item_film);
			} else if (MODE_VALUE == SECOND_MODE) {
				((UserSettingInitialActivity) getActivity())
						.setNavigationImage(R.drawable.item_back,
								Integer.MAX_VALUE);
			}
		} else if (getActivity() instanceof HomeActivity) {
			((HomeActivity) getActivity()).showRightButtonImg(false);
			((HomeActivity) getActivity()).setLeftImage(R.drawable.item_back);
			((HomeActivity) getActivity()).setActivityTitle(mTitle);
		}
	}

	public static Fragment create(int mode) {
		SportsFragment fragment = new SportsFragment();
		Bundle bundle = new Bundle();
		bundle.putInt(MODE, mode);
		fragment.setArguments(bundle);
		return fragment;
	}

	@Override
	public void onClick(View v) {
		HOBBY_TYPE = Constant.SPORT;
		super.onClick(v);
	}
}
